package jnpf.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.File;

@Configuration
public class FileStorageConfig {

    @Value("${config.file-storage.local-plus[0].base-path}")
    private String rawBasePath;
    
    private String formattedBasePath;

    @PostConstruct
    public void init() {
        // 统一处理路径分隔符
        formattedBasePath = rawBasePath.replace("/", File.separator)
                                     .replace("\\", File.separator);
        
        // 确保路径以分隔符结尾
        if (!formattedBasePath.endsWith(File.separator)) {
            formattedBasePath += File.separator;
        }
    }

    public String getBasePath() {
        return formattedBasePath;
    }
}